<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
	<button>send</button>
</body>
<script>
	const btn = document.querySelector("button");
	btn.onclick = function(){
		const xhr = new XMLHttpRequest();
		xhr.timeout = 2000;// 超时时间
		xhr.open("get","/weibo");
		xhr.send();
		xhr.onload = function(){
			console.log(xhr.response);
		}
		xhr.ontimeout = function(){
			// 当发送的请求时间超过了指定的timout时间后执行
			console.log("ontimeout");
		}
	}
	
</script>
</html>